public class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int hashCode() {  //重写hashCode方法
        int s1 = this.name.hashCode();
        int s2 = this.age;
        return s1+s2;
    }

    @Override
    public boolean equals(Object obj) {  //重写equals方法
        if (this == obj) {
            return true;
        }
        if (obj instanceof Person) {
            if (this.name == ((Person) obj).getName() && this.age == ((Person) obj).getAge()) {
                return true;
            }
            return false;
        }
        return false;
    }

    @Override
    public String toString() {
        return "[name = " + name + " ,age = " + age + "]";
    }
}
